import java.util.Arrays;
import java.util.Random;

//生成随机验证码
public class Test {
    public static void main(String[] args) {
        //创建一个包含字母大小写的字符串
        char[] crr = new char[52 + 10];
        for (int i = 0; i < crr.length; i++) {
            if(i < 26){
                crr[i] = (char)(65 + i);
            }else if(i >= 26 && i < 52){
                crr[i] = (char)(97 + i - 26);
            }else {
                crr[i] = (char)('0' + i - 52);
            }
        }
//        System.out.println(Arrays.toString(crr));
        //定义一个字符串用于存放验证码
        String srr = "";
        //生成四位随机验证码
        Random r = new Random();
        for (int i = 0; i < 4; i++) {
            int index = r.nextInt(crr.length);
            srr += crr[index];
        }
        System.out.println(srr);
    }
}
